Skip to content

Add php-pipe-op face for the PHP 8.5 pipe operator#821

Merged
zonuexe merged 1 commit into
masterfrom
feat/php-pipe-op
Jul 16, 2026
Merged

Add php-pipe-op face for the PHP 8.5 pipe operator#821
zonuexe merged 1 commit into
masterfrom
feat/php-pipe-op

Conversation

@zonuexe

@zonuexe zonuexe commented Jul 16, 2026

Copy link
Copy Markdown
Member

The problem

PHP 8.5's pipe operator came out half-fontified. No rule matched |>, so the comparison-operator matcher — whose [<>]=? alternative claims a bare > — took the second character and left the first one plain:

;; $slug = $title |> trim(...);
'|' → nil
'>' → php-comparison-op

So |> rendered as an unstyled pipe followed by what looks like a comparison operator.

The fix

php-pipe-op inherits php-operator, like every other operator face in php-face.el:

(defface php-pipe-op '((t (:inherit php-operator)))
  "PHP Mode face used to the pipe operator (|>).
The operator was added in PHP 8.5."
  :tag "PHP Pipe Op")

Its font-lock rule sits ahead of the comparison operators so it wins the >. The rule is deliberately narrow (|> only), so nothing else moves.

Verification

Both characters now get the face, and the operators the new rule could have stolen from are unchanged:

token face(s)
|> php-pipe-op php-pipe-op
|| php-logical-op ×2 (unchanged)
>= php-comparison-op ×2 (unchanged)
> php-comparison-op (unchanged)
<=> php-comparison-op ×3 (unchanged)
| nil (unchanged)

The test asserts faces directly rather than through a .faces golden file — golden files that contain doc comments are Emacs-version-sensitive here (hence the existing .24/.27 variants), and this way the test states its intent and stays version-robust. Verified that it fails before the change ((nil php-comparison-op)) and passes after.

Byte-compiles with no new warnings; full suite green, including every existing .faces fixture.

Note

This targets the v1.28 (CC Mode) series so both it and the cc-mode independent rewrite fontify the pipe the same way — the bug is identical in both engines, since they share this matcher. The matching rule for the new php-mode.el in #812 follows there.

The pipe operator came out half-fontified.  No rule matched `|>', so
the comparison-operator matcher -- whose `[<>]=?' alternative claims a
bare `>' -- took the second character and left the first one plain:

    '|' -> nil
    '>' -> php-comparison-op

Give it a face of its own.  php-pipe-op inherits php-operator like the
rest of the operator faces, and its rule sits ahead of the comparison
operators so it wins the `>'.

The rule is deliberately narrow (`|>' only), so nothing else moves:
`||', `>=', `>', `===', `<=>', `=>' and a bare `|' all keep the faces
they had.  A test pins that down alongside the pipe itself.

See https://www.php.net/releases/8.5/en.php
@zonuexe
zonuexe merged commit 5c4ebd8 into master Jul 16, 2026
14 checks passed
zonuexe added a commit that referenced this pull request Jul 16, 2026
php-pipe-op and its rule arrived on master (#821) in the CC Mode based
php-mode.el, which this branch renames to php-cc-mode.el; the new mode
body needs the same rule for the same reason.  Without it the
comparison-operator matcher claims the `>' of `|>' and leaves the `|'
plain.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant